<extend name="Public/base"/>
<block name="body">
    <div class="main-title">
        <h2>新增会员</h2>
    </div>
    <form action="{:U()}" method="post" class="form-horizontal" enctype="multipart/form-data">
        <div class="form-item">
            <label class="item-label">用户名<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large user" name="user" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">邮箱<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large email" name="email" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">密码<span class="check-tips"></span></label>
            <div class="controls">
                <input type="password" class="text input-large pwd" name="pwd" value="">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">电话<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large tall" name="tall" value="">
            </div>
        </div>
        <div class="form-item">
             <label class="item-label">头像<span class="check-tips"></span></label>
            <div class="controls">
                <input type="file"  name="file" id="doc" multiple="multiple"  style="width:200px;border-radius:20px" onchange="javascript:setImagePreviews();" accept="image/*" />
                <div id="dd" style=" width:200px;"></div>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">会员状态<span class="check-tips"></span></label>
             <input type="radio" name="status" value="0">禁用
             <input type="radio" name="status" value="1">不禁用
        </div>  
        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Suser/index')}');
    </script>
    <script>
         $(function(){
            $(".user").blur(function(){
                var user=$(".user").val();
                $.get("{:U('Suser/ajuser')}",{user:user},
                    function(data){
                      if(data.status==0){
                          $(".user").nextAll().remove();
                          $(".user").after(data.data);
                      }else{
                          $(".user").nextAll().remove();
                          $(".user").after(data.data);
                      }
                });
            });
         });

         $(function(){
            $(".email").blur(function(){
                var email=$(".email").val();
                $.get("{:U('Suser/ajemail')}",{email:email},
                    function(data){
                      if(data.status==0){
                          $(".email").nextAll().remove();
                          $(".email").after(data.data);
                      }else{
                          $(".email").nextAll().remove();
                          $(".email").after(data.data);
                      }  
                });
            });
         });

         $(function(){
            $(".tall").blur(function(){
                var tall=$(".tall").val();
                $.get("{:U('Suser/ajtall')}",{tall:tall},
                    function(data){
                      if(data.status==0){
                          $(".tall").nextAll().remove();
                          $(".tall").after(data.data);
                      }else{
                          $(".tall").nextAll().remove();
                          $(".tall").after(data.data);
                      }  
                });
            });
         });
    </script>
    <script type="text/javascript">

    //下面用于多图片上传预览功能

    function setImagePreviews(avalue) {

        var docObj = document.getElementById("doc");

        var dd = document.getElementById("dd");

        dd.innerHTML = "";

        var fileList = docObj.files;

        for (var i = 0; i < fileList.length; i++) {            



            dd.innerHTML += "<div style='float:left' > <img id='img" + i + "'  /> </div>";

            var imgObjPreview = document.getElementById("img"+i); 

            if (docObj.files && docObj.files[i]) {

                //火狐下，直接设img属性

                imgObjPreview.style.display = 'block';

                imgObjPreview.style.width = '150px';

                //imgObjPreview.style.height = '200px';

                //imgObjPreview.src = docObj.files[0].getAsDataURL();

                //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式

                imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);

            }

            else {

                //IE下，使用滤镜

                docObj.select();

                var imgSrc = document.selection.createRange().text;

                alert(imgSrc)

                var localImagId = document.getElementById("img" + i);

                //必须设置初始大小

                localImagId.style.width = "150px";

                localImagId.style.height = "180px";

                //图片异常的捕捉，防止用户修改后缀来伪造图片

                try {

                    localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";

                    localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;

                }

                catch (e) {

                    alert("您上传的图片格式不正确，请重新选择!");

                    return false;

                }

                imgObjPreview.style.display = 'none';

                document.selection.empty();

            }

        }  



        return true;

    }

 

</script>
</block>